// 获取类的所有实例变量
//  NSObject+Ivars.m
//  InsuranceMarketing
//
//  Created by bihu_mac on 2018/2/26.
//  Copyright © 2018年 initial. All rights reserved.
//

#import <objc/runtime.h>
#import "NSObject+Ivars.h"

@implementation NSObject (Ivars)

- (NSArray *)getAllIvars{
    NSMutableArray * ivarsArray = [NSMutableArray array];
    unsigned int count;
    Ivar * ivars = class_copyIvarList([self class], &count);
    for (int i = 0; i < count; i++) {
        Ivar ivar = *(ivars + i);
//        [ivarsArray addObject:[NSString stringWithFormat:@"%s",ivar_getName(ivar)]];
        NSLog(@"ivar_getName %s",ivar_getName(ivar));
    }
    free(ivars);
    return ivarsArray;
}
@end
